Plots
gps %>%
select(pressInsufTime, H_LDepbin) %>%
group_by(H_LDepbin) %>%
count(pressInsufTime) %>%
filter(!is.na(H_LDepbin) & !is.na(pressInsufTime)) %>%
mutate(pct = n/sum(n)*100) %>%
ggplot(aes(pressInsufTime, pct, fill = H_LDepbin)) +
geom_col(position = "dodge") +
geom_label(aes(label = paste0(round(pct,0),"%"), y = pct - pct/3),
position = position_dodge(width = .9),
size = 5, colour = "white", show.legend = FALSE) +
scale_fill_wsj() +
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) +
scale_y_continuous(labels = scales::percent_format(scale = 1)) +
theme(legend.position = "top") +
labs(x = "Pressure experienced from insufficient time",
y = "",
fill = "",
caption = "8 values removed due to missing data\nLow deprivation n = 476\nHigh Deprivation n = 471") -> plot_1
plot_1

ggsave("plots/plot_1.png", plot_1, width = 12, height = 9, dpi = 300)
gps %>%
select(satJob, H_LDepbin) %>%
group_by(H_LDepbin) %>%
count(satJob) %>%
filter(!is.na(H_LDepbin) & !is.na(satJob)) %>%
mutate(pct = n/sum(n)*100) %>%
ggplot(aes(fct_rev(satJob), pct, fill = H_LDepbin)) +
geom_col(position = "dodge") +
geom_label(aes(label = paste0(round(pct,0),"%"), y = pct - pct/3),
position = position_dodge(width = .9),
size = 5, colour = "white", show.legend = FALSE) +
scale_fill_wsj() +
scale_x_discrete(labels = function(x) str_wrap(x, width = 10)) +
scale_y_continuous(labels = scales::percent_format(scale = 1)) +
theme(legend.position = "top") +
labs(x = "Overall Job Satisfaction",
y = "",
fill = "") -> plot_2
plot_2

plot_3 <-
gps %>%
select(ID, gender, age) %>%
mutate(age = age_group(age, by = 10),
gender = factor(gender, levels = c("male", "female"),
labels = c("Male", "Female"))) %>%
filter(!is.na(gender) & !is.na(age)) %>%
ggplot(aes(age, fill = gender)) +
geom_bar() +
scale_fill_wsj(guide = "none") +
facet_wrap(~gender) +
labs(x = "Age group",
y= "",
caption = "Excluding 164 records with missing data\ntotal n included = 2,301")
plot_3

ggsave("plots/plot_3.png", plot_3, width = 12, height = 9, dpi = 300)
gps %>%
select(starts_with("hours"), H_LDepbin) %>%
pivot_longer(hoursDirPatCare:hoursOther, names_to = "hours",
values_to = "values") %>%
filter(!is.na(values) & !is.na(H_LDepbin))%>%
ggplot(aes(hours, values, fill = H_LDepbin)) +
geom_boxplot()
